package com.neu.icloud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.icloud.entity.Product;
import com.neu.icloud.service.ProductService;

@RestController
@RequestMapping("/ProductController")
public class ProductController {

	@Autowired
	private ProductService productService;
	
	@RequestMapping("/allListProduct")
	public List<Product> allListProduct(Product product) throws Exception{
		return productService.allListProduct(product);
	}
	
	@RequestMapping("/findAllProductByFactoryId")
	public List<Product> findAllProductByFactoryId(Integer factoryId){
		return productService.findProductByFactoryId(factoryId);
	}
	
	@RequestMapping("/listProduct")
	public List<Product> listProduct(Integer productId) throws Exception{
		return productService.listProduct(productId);
	}
	
	@RequestMapping("/findProduct")
	public List<Product> listByProductName(String productName){
		return productService.listByProductName(productName);
	}
	
	@RequestMapping("/saveProduct")
	public int saveProduct(Product product) throws Exception{
		return productService.saveProduct(product);
	}
	
	@RequestMapping("/updateProduct")
	public int updateProduct(Product product) throws Exception{
		return productService.updateProduct(product);
	}
	
	@RequestMapping("/removeProduct")
	public int removeProduct(Product product) throws Exception{
		return productService.removeProduct(product);
	}
	
	@RequestMapping("/countProduct")
	public int countProduct(Product product) throws Exception{
		return productService.countProduct(product);
	}
	
	@RequestMapping("/queryProduct")
	 public List<Product> QueryProduct(String productName) throws Exception{
	  return productService.QueryProduct(productName);
	 }
}
